home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Shaders / TexturingAndModeling:AProceduralApproach / DPShaders / DPCloudPlane.sl < prev    next >
Encoding:
Text File  |  1995-03-22  |  1.1 KB  |  48 lines

  1. #include "proctext.h"
  2.  
  3. #define NTERMS 5
  4.  
  5. surface
  6. DPCloudPlane(
  7.     color cloudcolor = color (1,1,1);
  8.     )
  9. {
  10.     color Ct;
  11.     point Psh;
  12.     float i, amplitude, f;
  13.     float x, fx, xfreq, xphase;
  14.     float y, fy, yfreq, yphase;
  15.     uniform float offset = 0.5;
  16.     uniform float xoffset = 13;
  17.     uniform float yoffset = 96;
  18.     
  19.     Psh = transform("shader", P);
  20.     x = xcomp(Psh) + xoffset;
  21.     y = ycomp(Psh) + yoffset;
  22.  
  23.     xphase = 0.9; /* arbitrary */
  24.     yphase = 0.7; /* arbitrary */
  25.     xfreq = 2 * PI * 0.023;
  26.     yfreq = 2 * PI * 0.021;
  27.     amplitude = 0.3;
  28.     f = 0;
  29.     for (i = 0; i < NTERMS; i += 1) {
  30.         fx = amplitude *
  31.             (offset + cos(xfreq * (x + xphase)));
  32.         fy = amplitude *
  33.             (offset + cos(yfreq * (y + yphase)));
  34.         f += fx * fy;
  35.         xphase = PI/2 * 0.9 * cos(yfreq * y);
  36.         yphase = PI/2 * 1.1 * cos(xfreq * x);
  37.     
  38.         xfreq *= 1.9 + i * 0.1; /* approximately 2 */
  39.         yfreq *= 2.2 - i * 0.08; /* approximately 2 */
  40.         amplitude *= 0.707;
  41.     }
  42.     f = clamp(f, 0, 1);
  43.  
  44.     Ct = mix(Cs, cloudcolor, f);
  45.     Oi = Os;
  46.     Ci = Os * Ct;
  47. }
  48.